/*
 * @Author: minglic minglic@foxmail.com
 * @Date: 2023-11-04 15:07:51
 * @LastEditors: minglic minglic@foxmail.com
 * @LastEditTime: 2023-11-04 15:30:15
 * @FilePath: \go2023\core\utils\data\impl\model.go
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
package impl

import "sxk.games/m/v2/core/utils/data"

type Model struct{}

func (*Model) Create(model any) error {
	return data.GetDb().Create(model).Error
}

func (*Model) Delete(model any) error {
	return data.GetDb().Delete(model).Error
}

func (*Model) Update(model any) error {
	return data.GetDb().Save(model).Error
}

func (*Model) List(model any, page, size int, sort any, query any, args ...any) error {
	return data.GetDb().Where(query, args...).Limit(size).Offset((page - 1) * size).Order(sort).Find(model).Error
}
